﻿using System;
using System.Collections.Generic;
using NFine.Code;
using NFine.Domain._03_Entity.Biz;
using NFine.Domain._04_IRepository.Biz;
using NFine.Repository.Biz;

namespace NFine.Application.Biz
{
    public class UserBankApp
    {
        private IUserBankRepository userBankRepository = new UserBankRepository();


        public bool AddBank(UserBankEntity userBankEntity)
        {
            userBankEntity.F_Id = Common.GuId();
            userBankEntity.F_CreateTime = DateTime.Now;
            int result = userBankRepository.Insert(userBankEntity);
            return result > 0 ? true : false;
        }

        public bool DelBank(string userBankId)
        {
            UserBankEntity ub = new UserBankEntity();
            ub.F_Id = userBankId;
            return userBankRepository.Delete(ub)>0;
        }

        public List<UserBankEntity> GetUserBankInfo(string userId)
        {
            var expression = ExtLinq.True<UserBankEntity>();
            expression = expression.And(a => a.F_UserId == userId);

            return userBankRepository.FindList(expression);
        }

    }
}